﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Globalization;
using Physio10Context;

namespace Physio_Clinic
{
    public partial class LogReport : System.Web.UI.Page
    {
        public Qf8soUser currentUser = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["currentUser"] != null)
            {
                currentUser = (Qf8soUser)Session["currentUser"];
                //userId = (int)Session["currentUserId"];

            }

            ReadTextFile();           
            //WriteTextFile();
            //System.Console.WriteLine(DateTime.Now.ToLongDateString());
        }

        private void ReadTextFile()
        {
            StreamReader StrWer;
            try
            {
                StrWer = File.OpenText(Server.MapPath("Log/") + "log.txt");
                while (!(StrWer.EndOfStream))
                {
                    this.lblText.Text = this.lblText.Text + StrWer.ReadLine() + "<br>";
                }
                StrWer.Close();
            }
            catch (Exception ex)
            {
                this.lblText.Text = "Read failed. (" + ex.Message + ")";
            }
        }

        private void WriteTextFile()
        {
            string path = @"C:\Users\suki\Documents\Visual Studio 2010\Projects\physio10\Physio_Clinic\Physio_Clinic\Log\log.txt";
            
            try
            {
                TextWriter writer = new StreamWriter(path);
                //StrWer = File.CreateText(Server.MapPath("MyFiles/") + "thaicreate.txt");
                writer.Write("www.ThaiCreate.Com");
                writer.Write("Version 2009");
                writer.WriteLine("");
                writer.WriteLine("www.ThaiCreate.Com");
                writer.WriteLine("Version 2009");
                writer.Close();
            }
            catch (Exception ex)
            {
                
            }
        }
    }
}